<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 *
 */
$styleSheet = "orange";
$pageNO = isset($_POST['pageNO'])?$_POST['pageNO']:'1';

	function getNextSortOrder($curSortOrder) {
		switch ($curSortOrder) {
			case 'null' :
				return 'ASC';
				break;
			case 'ASC' :
				return 'DESC';
				break;
			case 'DESC'	:
				return 'ASC';
				break;
		}
	}
	
	    $GLOBALS['lang_Common_SortAscending'] = $lang_Common_SortAscending;
    $GLOBALS['lang_Common_SortDescending'] = $lang_Common_SortDescending;

	function nextSortOrderInWords($sortOrder) {
        return $sortOrder == 'ASC' ? $GLOBALS['lang_Common_SortDescending'] : $GLOBALS['lang_Common_SortAscending'];
	}
	$some = "";
	if(isset($_GET['action']) && isset($_GET['s'])) {
		$some = "&action={$_GET['action']}&s={$_GET['s']}";
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../../themes/<?php echo $styleSheet; ?>/css/style.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 6]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE6_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<!--[if IE]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<script type="text/javascript" src="../../themes/<?php echo $styleSheet;?>/scripts/style.js"></script>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="../../scripts/octopus.js"></script>
<script type="text/javascript">

	function nextPage() {
		i=document.standardView.pageNO.value;
		i++;
		document.standardView.pageNO.value=i;
		document.standardView.submit();
	}

	function prevPage() {
		var i=document.standardView.pageNO.value;
		i--;
		document.standardView.pageNO.value=i;
		document.standardView.submit();
	}

	function chgPage(pNO) {
		document.standardView.pageNO.value=pNO;
		document.standardView.submit();
	}
	
	function returnDelete() {
		$check = 0;
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if ((elements[i].type == 'checkbox') && (elements[i].checked == true)){
					$check = 1;
				}
			}
		}

		if ( $check == 1 ){
			document.standardView.delState.value = 'DeleteMode';
			document.standardView.pageNO.value=1;
			document.standardView.submit();
		}else{
			alert("<?php echo $lang_Error_SelectAtLeastOneRecordToDelete; ?>");
		}
	}


	function returnSearch() {
		if (document.standardView.loc_code.value == -1) {
			alert("<?php echo $lang_Common_SelectField; ?>");
			document.standardView.loc_code.Focus();
			return;
		};
		document.standardView.captureState.value = 'SearchMode';
		document.standardView.pageNO.value=1;
		document.standardView.submit();
	}

	function doHandleAll()
	{
		with (document.standardView) {
			if(elements['allCheck'].checked == false){
				doUnCheckAll();
			}
			else if(elements['allCheck'].checked == true){
				doCheckAll();
			}
		}
	}

	function doCheckAll() {
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox') {
					elements[i].checked = true;
				}
			}
		}
	}

	function doUnCheckAll()
	{
		with (document.standardView) {
			for (var i=0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox') {
					elements[i].checked = false;
				}
			}
		}
	}
	
	/**
	 * If at least one day is unchecked, main check box would be unchecked
	 */

	function unCheckMain() {
		noOfCheckboxes = 0;
		noOfCheckedCheckboxes = 0;

		with (document.getElementById('standardView')) {
			for (i = 0; i < elements.length; i++) {
				if (elements[i].type == 'checkbox' && elements[i].name != 'allCheck') {
					noOfCheckboxes++;
					if (elements[i].checked == true) {
						noOfCheckedCheckboxes++;
					}

				}
			}
		}

		document.getElementById('allCheck').checked = (noOfCheckboxes == noOfCheckedCheckboxes);
	}

	function clear_form() {
		document.standardView.loc_code.options[0].selected=true;
		document.standardView.loc_name.value='';
	}
</script>
<div class="outerbox">
	<form name="standardView" id="standardView" method="post" action="<?php echo $_SERVER['PHP_SELF']?>?adcode=<?php echo $_GET['adcode'].$some; ?>&sortField=<?php echo $this->getArr['sortField']; ?>&amp;sortOrder<?php echo $this->getArr['sortField']; ?>=<?php echo $this->getArr['sortOrder'.$this->getArr['sortField']]?>">

		<div class="mainHeading"><h2>考勤有效记录</h2></div>
		<input type="hidden" name="captureState" value="<?php echo isset($this->postArr['captureState'])?$this->postArr['captureState']:''?>" />
		<input type="hidden" name="pageNO" value="<?php echo $pageNO;?>" />
		<input type="hidden" name="empID" value="" />


		<?php if($some == "") include("../../templates/attendance/Search.php");?>

			<div class="actionbar">
				<div class="actionbuttons">
					<input type="button" class="plainbtn"
					<?php echo ($locRights['add']) ? 'onclick="returnAdd();"' : 'style=visibility:hidden;'; ?>
						onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
						value="<?php echo $lang_Common_Add;?>" />


						<input type="button" class="plainbtn"
						<?php echo ($locRights['delete']) ? 'onclick="returnDelete();"' : 'style=visibility:hidden;'; ?>
							onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
							value="<?php echo $lang_Common_Delete;?>" />


				</div>
				<div class="noresultsbar"><?php echo (empty($emplist)) ? $norecorddisplay : '';?></div>
				<div class="pagingbar">
				<?php
					$commonFunc = new CommonFunctions();
					$pageStr = $commonFunc->printPageLinks($records['Allcount'], $pageNO);
					$pageStr = preg_replace(array('/#first/', '/#previous/', '/#next/', '/#last/'), array($lang_empview_first, $lang_empview_previous, $lang_empview_next, $lang_empview_last), $pageStr);

					echo $pageStr;

					for ($j = 0; $j < 11; $j++) {
						if (!isset($this->getArr['sortOrder'.$j])) {
							$this->getArr['sortOrder'.$j] = 'null';
						}
					}
				?>
				</div>
			<br class="clear" />
			</div>
			<br class="clear" />
				<table cellspacing="0" cellpadding="0" class="data-table">
					<thead>
					<tr>
						<td scope="col">日期</td>
						<td scope="col">员工编号</td>
						<td scope="col">员工名字</td>
						<td scope="col">部门</td>
						<td scope="col">上班打卡</a></td>
						<td scope="col">中间下班打卡</td>
						<td scope="col">中间上班打卡</td>
						<td scope="col">下班打卡</td>
						<td scope="col">考勤状态</td>
						<!--<td scope="col"> 迟到 </td>
						<td scope="col"> 早退 </td>-->
						<td scope="col"> 平时加班 </td>
						<td scope="col"> 周末加班 </td>
						<td scope="col"> 节假日加班 </td>
					</tr>
					</thead>

					<tbody>
					<?php
							$list = $records['list'];
							//for ($j=0; $j<count($list);$j++) {
								//$descField=$list[$j][1];
								if(count($list) > 0 ) {
								foreach ($list as $key => $val) {
									
								$subDivision = "-";
								$compStructObj = new CompStruct();
								$compStructObj->buildAllWorkStations();
								if (isset($val['work_station']) && !empty($val['work_station'])) {
									$subDivision = $compStructObj->fetchHierarchString($val['work_station']);
								}

					?>
								<tr class="<?php echo $cssClass;?>">
									<td ><?php echo $val['riqi']; ?></td>
									
									<td ><?php echo $val['employee_id']?></td>
									<td ><?php echo $val['emp_firstname'].$val['emp_lastname']?></td>
									<td ><?php echo $subDivision?></td>
									<td ><?php echo $val['starttime'] > 0 ?@date("Y-m-d H:i:s",$val['starttime']):" - "; ?></td>
									
									<td ><?php echo $val['MiddleAftime'] > 0 ?@date("Y-m-d H:i:s",$val['MiddleAftime']):" - "; ?></td>
									<td ><?php echo $val['MiddleSttime'] > 0 ?@date("Y-m-d H:i:s",$val['MiddleSttime']):" - "; ?></td>
									
									<td ><?php echo $val['endtime'] > 0 ?@date("Y-m-d H:i:s",$val['endtime']):" - "; ?></td>
									
									<td ><?php echo $val['beizhu']; ?></td>
									
									<!--<td ><?php echo $val['beizhu']; ?></td>
									<td ><?php echo $val['beizhu']; ?></td>-->
									<td ><?php echo $val['pcOTtime']; ?></td>
									<td ><?php echo $val['WeekOTtime']; ?></td>
									<td ><?php echo $val['HolidayOTtime']; ?></td>
	
							</tr>
						<?php } } ?>
					</tbody>
				</table>
	</form>
</div>
<script type="text/javascript">
//<![CDATA[
    if (document.getElementById && document.createElement) {
        roundBorder('outerbox');
    }
//]]>
</script>
